import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import Validate from './common/validate'
import { TransformInterceptor } from './transform.interceptor'
import { NestExpressApplication } from '@nestjs/platform-express'

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule)
  // 全局注册管道验证
  app.useGlobalPipes(new Validate())
  // 注册全局拦截器
  app.useGlobalInterceptors(new TransformInterceptor())
  // 添加全局请求前缀
  app.setGlobalPrefix('api')
  // 静态资源访问 访问上传图片地址设置
  app.useStaticAssets('uploads', { prefix: '/uploads' })
  await app.listen(3000)
}
bootstrap()
